package com.gtxc.kotlinmvvm.viewmodle

import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.aleyn.mvvm.base.BaseViewModel
import com.blankj.utilcode.util.ToastUtils
import com.gtxc.kotlinmvvm.network.request.MediaListBean
import com.gtxc.kotlinmvvm.network.request.verifyNewVersionBean
import com.gtxc.kotlinmvvm.ui.activity.HomeActivity
import com.gtxc.kotlinmvvm.utlis.AppUtils
import com.mot.st.network.request.ApiNetWork
import listener.Md5CheckResultListener
import listener.UpdateDownloadListener
import update.UpdateAppUtils.getInstance
import update.UpdateAppUtils.uiConfig
import update.UpdateAppUtils.updateConfig

class HomeViewModle : BaseViewModel(){

    val currentapiVersion = AppUtils.getVersionCode(getApplication())
    val mediaListBean = MutableLiveData<MediaListBean>()

    val verifyNewVersionBean = verifyNewVersionBean("", 1, currentapiVersion)
    val dailiok = MutableLiveData<Boolean>()
    init {
        launchUI {
            val result =     ApiNetWork.getInstance().gethomepage()
            if (result.success){
                mediaListBean.value=result.resultObj
                Log.i("dwdedewdwedw", ": wed:" + result.resultObj)
            }
            Log.i("dwdedewdwedssssssw", ": wed:" + currentapiVersion)
            val resulta =     ApiNetWork.getInstance().getverifyNewVersion(verifyNewVersionBean)
            if (resulta.success){
                Log.i("dwdedewdwedssssssw", ": wed:" + resulta.resultObj.version.versionCode)
            }
        }
    }
    //    点击领取代理
    fun basicsTaskConmit(){
        launchUI {
            val resultbasicsTaskConmit =     ApiNetWork.getInstance().basicsTaskConmit()
            dailiok.value=resultbasicsTaskConmit.success
            if (resultbasicsTaskConmit.success){
                Log.i("44444", ": wed:" + resultbasicsTaskConmit.message)
            }else{
                ToastUtils.showShort(resultbasicsTaskConmit.message)
            }
        }
    }
    //    闪电图标每日任务接口
    fun getlightning(){
        launchUI{
            Log.i("dwdevvv", ": wed:" +66666)
            val resultgetlightning =   ApiNetWork.getInstance().basicsTaskConmit()
            if (resultgetlightning.success){
                Log.i("dwdevvv", ": wed:" +66666)
                Log.i("dwdevvv", ": wed:" + resultgetlightning.resultObj)
            }
        }
    }


}